# -*- encoding:utf-8 -*-


class StringDemo:
    def _test_string(self):
        """
        sd = StringDemo()
        sd._test_string()
        """
        str_ = 'hello world'
        # str.find()查询到指定字符的最小索引值
        print 'find结果: ', str_.find('e')
        # str.rfind()查询到指定字符的最大索引值
        print 'rfind结果: ', str_.rfind('o')
        # str.count()
        print 'count结果: ', str_.count('l')
        # str.replace()
        print 'replace结果: ', str_.replace('r', 'R')
        # str.split()
        print 'split结果:', str_.split(' ', 0)
        # str.capitalize()
        print 'capitalize结果: ', str_.capitalize()
        # str.title()
        print 'title结果: ', str_.title()
        # str.startswith()
        print 'startswith结果: ', str_.startswith('a')
        # str.endswith()
        print 'endswith结果: ', str_.endswith('o')
        # str.lower()
        print 'lower结果: ', str_.lower()
        # str.upper()
        print 'upper结果: ', str_.upper()
        # str.ljust()
        print 'ljust结果: ', str_.ljust(20)
        # str.rjust()
        print 'rjust结果: ', str_.rjust(20)
        # str.center()
        print 'center结果: ', str_.center(20)
        # str.lstrip()
        print 'lstrip结果: ', str_.lstrip('l')
        # str.rstrip()
        print 'rstrip结果: ', str_.rstrip('d')
        # str.strip()
        print 'strip结果: ', str_.strip('h')
        # str.rindex()
        print 'rindex结果: ', str_.rindex('o')
        # str.partition()
        print 'partition结果: ', str_.partition('w')
        # str.rpartition()
        print 'rpartition结果: ', str_.rpartition('w')
        # str.splitlines()
        print 'splitlines结果: ', str_.splitlines()
        # str.isalpha()
        print 'isalpha结果: ', str_.isalpha()
        # str.isdigit()
        print 'isdigit结果: ', str_.isdigit()
        # str.isalnumz()
        print 'isalnum结果: ', str_.isalnum()
        # str.isspace()
        print 'isspace结果: ', str_.isspace()
        # str.join()
        print 'join结果: ', ''.join(str_.split('w'))


if __name__ == '__main__':
    sd = StringDemo()
    sd._test_string()
